TARGET  = payload
OBJS    = payload.o

PREFIX  = arm-vita-eabi
CC      = $(PREFIX)-gcc
AS      = $(PREFIX)-as
LD      = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
CFLAGS  = -fPIE -fno-zero-initialized-in-bss -std=c99 -mcpu=cortex-a9 -Os -mthumb
LDFLAGS = -T linker.x -nostartfiles -nostdlib -pie

all: $(TARGET).bin

%.bin: %.elf
	$(OBJCOPY) -S -O binary $^ $@

$(TARGET).elf: $(OBJS)
	$(LD) $(LDFLAGS) $^ -o $@

%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

clean:
	@rm -f $(TARGET).bin $(TARGET).elf $(OBJS)
